package com.gbas.comu.servlet.struts;

import com.gbas.comu.dao.DaoService;
import com.gbas.comu.model.Liga;
import com.gbas.comu.service.EquipoService;
import com.gbas.comu.service.JugadorService;
import com.gbas.comu.service.LigaService;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.MappingDispatchAction;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

public class LigaActions extends MappingDispatchAction {
    public ActionForward show(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse response) throws Exception {
        httpServletRequest.setAttribute("ligas", DaoService.getLigaDAO().findAll());
        return actionMapping.findForward("success");
    }
    public ActionForward create(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse response) throws Exception {
        LigaService.creaLiga();
        return actionMapping.findForward("success");
    }

    public ActionForward playJornada(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse response) throws Exception {
        LigaService.juegaJornada();
        return actionMapping.findForward("success");
    }


}
